package com.unknowpupil.web.component.aspect;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @Classname: UrlCache
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2019/11/5 14:21
 * @Description: 内存缓存
 * @Version: 1.0
 */
@Configuration
public class UrlCache {
    @Bean
    public Cache<String, Integer> getCache() {
        /**
         *  缓存有效期为2秒
         */
        return CacheBuilder.newBuilder().expireAfterWrite(3L, TimeUnit.SECONDS).build();
    }
}
